package com.example.composedialogdemo.dialog

import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.window.DialogProperties
import com.example.composedialogdemo.R

/**
 * @author: njb
 * @date:   2025/8/16 14:17
 * @desc:   描述
 */
@Composable
fun ErrorDialog(
    show: Boolean,
    onDismiss:() -> Unit,
    onExit:() -> Unit
){
    if(show){
        AlertDialog(
            properties = DialogProperties(
            dismissOnBackPress =   false,
            dismissOnClickOutside = false
            ),
            title = {
                Text(
                    text = stringResource(id = R.string.warm_reminder),
                    style = MaterialTheme.typography.headlineSmall
                )
            },
            text = {
                Text(
                    text =stringResource(id = R.string.ble_lock_enable_ble_hint),
                    style = MaterialTheme.typography.bodyLarge)
            },
            confirmButton = {
                Button(onClick = onExit) {
                    Text(stringResource(id = R.string.cancel))
                }
            },
            // 取消按钮不显示
            dismissButton = {},
            // 点击外部不关闭（已通过properties配置，这里只是双重保障）
            onDismissRequest = onDismiss
        )
    }
}
